
//
//  KNavigationSelectView.m
//  DrugPin
//
//  Created by guohe on 2018/9/10.
//  Copyright © 2018年 outang. All rights reserved.
//

#import "KNavigationSelectView.h"

@implementation KNavigationSelectView


- (instancetype)initwithNaviType:(KNaviType)naviType
{
    if (self == [super init]) {
        
        [self setupUI];
        switch (naviType) {
            case KNaviType_HomePage:{
                self.redEnvelopeActivityBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                self.cultivateActivityBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                self.scratchRedEnvelopeBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                [self.redEnvelopeActivityBtn setTitle:@"红包活动" forState:UIControlStateNormal];
                [self.cultivateActivityBtn setTitle:@"培训活动" forState:UIControlStateNormal];
                [self.scratchRedEnvelopeBtn setTitle:@"抢费用" forState:UIControlStateNormal];
            }
                break;
                
            case KNaviType_Discovery:{
                self.redEnvelopeActivityBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                self.cultivateActivityBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                self.scratchRedEnvelopeBtn.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
                [self.redEnvelopeActivityBtn setTitle:@"专业阅读" forState:UIControlStateNormal];
                [self.cultivateActivityBtn setTitle:@"户外促销" forState:UIControlStateNormal];
                [self.scratchRedEnvelopeBtn setTitle:@"实战案例" forState:UIControlStateNormal];
            }
                break;
                
            default:
                break;
        }
        
    }
    return self;
}

- (void)setupUI
{
    [self addSubview:self.redEnvelopeActivityBtn];
    [self addSubview:self.cultivateActivityBtn];
    [self addSubview:self.scratchRedEnvelopeBtn];
    [self addSubview:self.bgLine];

    CGFloat space = KScreenWidth/3;
    [self.redEnvelopeActivityBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.mas_equalTo(self);
        make.width.mas_equalTo(space);
    }];
    
    [self.bgLine mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.redEnvelopeActivityBtn.mas_bottom).mas_offset(-2);
        make.left.right.mas_equalTo(self.redEnvelopeActivityBtn);
        make.height.mas_equalTo(2);
    }];
    
    [self.cultivateActivityBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.redEnvelopeActivityBtn.mas_right);
        make.top.bottom.mas_equalTo(self);
        make.width.mas_equalTo(space);
    }];
    
    [self.scratchRedEnvelopeBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.cultivateActivityBtn.mas_right);
        make.top.bottom.mas_equalTo(self);
        make.width.mas_equalTo(space);
    }];
}

#pragma mark - getter
-(UIButton *)redEnvelopeActivityBtn
{
    if (!_redEnvelopeActivityBtn) {
        _redEnvelopeActivityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _redEnvelopeActivityBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_redEnvelopeActivityBtn setTitleColor:KColorOneAlpha(51,51,51) forState:UIControlStateNormal];
        [_redEnvelopeActivityBtn setTitleColor:KColorOneAlpha(48,138,245) forState:UIControlStateSelected];
    }
    return _redEnvelopeActivityBtn;
}

-(UIButton *)cultivateActivityBtn
{
    if (!_cultivateActivityBtn) {
        _cultivateActivityBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _cultivateActivityBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_cultivateActivityBtn setTitleColor:KColorOneAlpha(51,51,51) forState:UIControlStateNormal];
        [_cultivateActivityBtn setTitleColor:KColorOneAlpha(48,138,245) forState:UIControlStateSelected];
        
    }
    return _cultivateActivityBtn;
}

-(UIButton *)scratchRedEnvelopeBtn
{
    if (!_scratchRedEnvelopeBtn) {
        _scratchRedEnvelopeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        _scratchRedEnvelopeBtn.titleLabel.font = [UIFont systemFontOfSize:17];
        [_scratchRedEnvelopeBtn setTitleColor:KColorOneAlpha(51,51,51) forState:UIControlStateNormal];
        [_scratchRedEnvelopeBtn setTitleColor:KColorOneAlpha(48,138,245) forState:UIControlStateSelected];
        
    }
    return _scratchRedEnvelopeBtn;
}

-(UIView *)bgLine{
    if (!_bgLine) {
        _bgLine = [[UIView alloc] init];
        _bgLine.backgroundColor = KColorOneAlpha(48,138,245);
    }
    return _bgLine;
}
@end
